{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 为最后推荐系统做准备"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'divide': 'raise', 'over': 'warn', 'under': 'ignore', 'invalid': 'warn'}"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from file_titles import *\n",
    "\n",
    "import os\n",
    "import pickle as cPickle\n",
    "import numpy as np\n",
    "import scipy.io as sio\n",
    "import scipy.sparse as ss\n",
    "from numpy.random import random  \n",
    "from collections import defaultdict\n",
    "np.seterr(divide='raise', invalid='raise')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 将所有特征串联起来，构成RS_Train.csv\n",
    "#RS_Test.csv\n",
    "\n",
    "class RecommonderSystem:\n",
    "  def __init__(self):\n",
    "    # 读入数据做初始化|\n",
    "    \n",
    "    #用户和活动新的索引\n",
    "    self.userIndex = cPickle.load(open(userIndex_file_title, 'rb'))\n",
    "    self.eventIndex = cPickle.load(open(eventIndex_file_title, 'rb'))\n",
    "    self.n_users = len(self.userIndex)\n",
    "    self.n_items = len(self.eventIndex)\n",
    "    \n",
    "    #用户-活动关系矩阵R\n",
    "    #在train_SVD会重新从文件中读取,二者要求的格式不同，来不及统一了:(\n",
    "    self.userEventScores = sio.mmread(userEventScores_file_title).todense()\n",
    "    \n",
    "    #倒排表\n",
    "    ##每个用户参加的事件\n",
    "    self.itemsForUser = cPickle.load(open(eventsForUser_file_title, 'rb'))\n",
    "    ##事件参加的用户\n",
    "    self.usersForItem = cPickle.load(open(usersForEvent_file_title, 'rb'))\n",
    "    \n",
    "    #基于模型的协同过滤参数初始化,训练\n",
    "    self.init_SVD()\n",
    "    self.train_SVD(trainfile = train_file_title)\n",
    "    \n",
    "    #根据用户属性计算出的用户之间的相似度\n",
    "    self.userSimMatrix = sio.mmread(US_userSimMatrix_file_title).todense()\n",
    "    \n",
    "    #根据活动属性计算出的活动之间的相似度\n",
    "    self.eventPropSim = sio.mmread(eventPropSim_file_title).todense()\n",
    "    self.eventContSim = sio.mmread(eventContSim_file_title).todense()\n",
    "    \n",
    "    #每个用户的朋友的数目\n",
    "    self.numFriends = sio.mmread(UF_numFriends_file_title)\n",
    "    #用户的每个朋友参加活动的分数对该用户的影响\n",
    "    self.userFriends = sio.mmread(UF_userFriends_file_title).todense()\n",
    "    \n",
    "    #活动本身的热度\n",
    "    self.eventPopularity = sio.mmread(EA_eventPopularity_file_title).todense()\n",
    "\n",
    "  def init_SVD(self, K=20, alpha = 0.01, lambda_default = 1, lambda_u = None, lambda_i = None, lambda_bu = None, lambda_bi = None):\n",
    "    #初始化模型参数（for 基于模型的协同过滤SVD_CF） \n",
    "    stored_data = np.load(LFM_model_data)\n",
    "    self.mu = stored_data['mu']\n",
    "    self.bu = stored_data['bu']\n",
    "    self.bi = stored_data['bi']\n",
    "    self.P = stored_data['P']\n",
    "    self.Q = stored_data['Q']\n",
    "    self.lambda_u = stored_data['lambda_u']\n",
    "    self.lambda_i = stored_data['lambda_i']\n",
    "    self.lambda_bu = stored_data['lambda_bu']\n",
    "    self.lambda_bi = stored_data['lambda_bi']\n",
    "          \n",
    "  def train_SVD(self, trainfile = train_file_title):\n",
    "    #训练SVD模型（for 基于模型的协同过滤SVD_CF）\n",
    "    #gamma：为学习率\n",
    "    #Lambda：正则参数\n",
    "    \n",
    "    #this is implement outside this file\n",
    "    e = np.zeros((self.n_users, self.n_items))\n",
    "    for i in range(self.n_users):\n",
    "        for j in range(self.n_items):\n",
    "            if self.userEventScores[i, j]:\n",
    "                e[i, j] = self.userEventScores[i, j] - (self.mu + self.bu[i] + self.bi[j] + np.dot(self.P[i,:],self.Q[j,:].T))\n",
    "\n",
    "       \n",
    "    total_loss = np.square(e).sum() + self.lambda_u * np.square(self.P).sum() + self.lambda_i * np.square(self.Q).sum() + \\\n",
    "                                            self.lambda_bu * np.square(self.bu).sum() + self.lambda_bi * np.square(self.bi).sum()\n",
    "    total_loss /= 2\n",
    "    # 请补充完整SVD模型训练过程\n",
    "    print(\"SVD trained, loss \", total_loss)\n",
    "    \n",
    "  def pred_SVD(self, uid, i_id):\n",
    "    #根据当前参数，预测用户uid对Item（i_id）的打分        \n",
    "    ans=self.mu + self.bi[i_id] + self.bu[uid] + np.dot(self.P[uid,:],self.Q[i_id, :].T)  \n",
    "        \n",
    "    #将打分范围控制在0-1之间\n",
    "    if ans>1:  \n",
    "        return 1  \n",
    "    elif ans<-1:  \n",
    "        return -1\n",
    "    return ans  \n",
    "\n",
    "  def sim_cal_UserCF(self, uid1, uid2 ):\n",
    "    #请补充基于用户的协同过滤中的两个用户uid1和uid2之间的相似度（根据两个用户对item打分的相似度）\n",
    "    similarity = 0.0\n",
    "    \n",
    "    if uid1 == uid2:\n",
    "        raise ValueError('compare to myself')\n",
    "    items1 = self.itemsForUser[uid1]\n",
    "    items2 = self.itemsForUser[uid2]\n",
    "    \n",
    "    items = items1 & items2\n",
    "    \n",
    "    if items:\n",
    "        X = self.userEventScores[uid1, list(items)]\n",
    "        Y = self.userEventScores[uid2, list(items)]\n",
    "        m1 = X - X.sum()/len(items)\n",
    "        m2 = Y - Y.sum()/len(items)\n",
    "        tmp = np.sqrt(np.square(m1).sum()) * np.sqrt(np.square(m2).sum())\n",
    "        if tmp:\n",
    "            similarity = (m1*m2.T).sum()/tmp\n",
    "    else:\n",
    "        similarity = 0\n",
    "    \n",
    "    return similarity  \n",
    "\n",
    "  def userCFReco(self, userId, eventId):\n",
    "    \"\"\"\n",
    "    根据User-based协同过滤，得到event的推荐度\n",
    "    基本的伪代码思路如下：\n",
    "    for item i\n",
    "      for every other user v that has a preference for i\n",
    "        compute similarity s between u and v\n",
    "        incorporate v's preference for i weighted by s into running aversge\n",
    "    return top items ranked by weighted average\n",
    "    \"\"\"\n",
    "    #请补充完整代码\n",
    "    ans = 0.0\n",
    "    u = self.userIndex[userId]\n",
    "    i = self.eventIndex[eventId]\n",
    "    \n",
    "    users = self.usersForItem[i]\n",
    "    users.discard(u)\n",
    "    uitems = self.itemsForUser[u]\n",
    "    if uitems:\n",
    "        uu = self.userEventScores[u, list(uitems)].sum()/len(uitems)\n",
    "\n",
    "        denominator = 0\n",
    "        numerator = 0\n",
    "        for other in users:\n",
    "            oitems = self.itemsForUser[other]\n",
    "            ou = self.userEventScores[other, list(oitems)].sum()/len(oitems)\n",
    "            sim = self.sim_cal_UserCF(u, other)\n",
    "            numerator += sim\n",
    "            denominator += sim*(self.userEventScores[other, i] - ou)\n",
    "\n",
    "        if numerator != 0:\n",
    "            ans = uu + denominator/numerator\n",
    "    if ans > 1:\n",
    "        ans = 1\n",
    "    elif ans < -1:\n",
    "        ans = -1\n",
    "    else:\n",
    "        pass\n",
    "    \n",
    "    return ans\n",
    "\n",
    "\n",
    "  def sim_cal_ItemCF(self, i_id1, i_id2):\n",
    "    #计算Item i_id1和i_id2之间的相似性\n",
    "    #请补充完整代码\n",
    "    similarity = 0.0\n",
    "    \n",
    "    if i_id1 == i_id2:\n",
    "        raise ValueError('compare to myself '+ str(i_id1))\n",
    "    \n",
    "    users1 = self.usersForItem[i_id1]\n",
    "    users2 = self.usersForItem[i_id2]\n",
    "    \n",
    "    users = users1 & users2\n",
    "    users = list(users)\n",
    "    score1 = self.userEventScores[users, i_id1]\n",
    "    score2 = self.userEventScores[users, i_id2]\n",
    "    \n",
    "    if users:\n",
    "        sum1 = 0\n",
    "        sum2 = 0\n",
    "        sum3 = 0\n",
    "        for user in users:\n",
    "            uitems = self.itemsForUser[user]\n",
    "            if uitems:\n",
    "                uu = self.userEventScores[user, list(uitems)].sum()/len(uitems)\n",
    "                u1 = self.userEventScores[user, i_id1] - uu\n",
    "                u2 = self.userEventScores[user, i_id2] - uu\n",
    "                sum1 += (u1*u2)\n",
    "                sum2 += u1**2\n",
    "                sum3 += u2**2\n",
    "        tmp = np.sqrt(sum2*sum3)\n",
    "        if tmp:\n",
    "            similarity = sum1/tmp\n",
    "    \n",
    "    return similarity     \n",
    "        \n",
    "    #return num/den  \n",
    "            \n",
    "  def eventCFReco(self, userId, eventId):    \n",
    "    \"\"\"\n",
    "    根据基于物品的协同过滤，得到Event的推荐度\n",
    "    基本的伪代码思路如下：\n",
    "    for item i \n",
    "        for every item j tht u has a preference for\n",
    "            compute similarity s between i and j\n",
    "            add u's preference for j weighted by s to a running average\n",
    "    return top items, ranked by weighted average\n",
    "    \"\"\"\n",
    "    #请补充完整代码\n",
    "    ans = 0.0\n",
    "    u = self.userIndex[userId]\n",
    "    i = self.eventIndex[eventId]\n",
    "    \n",
    "    items = self.itemsForUser[u]\n",
    "    \n",
    "    if items:\n",
    "        uu = self.userEventScores[u, list(items)].sum()/len(items)\n",
    "        sum1 = 0\n",
    "        sum2 = 0\n",
    "        items.discard(i)\n",
    "\n",
    "        for item in items:\n",
    "            sim = self.sim_cal_ItemCF(i, item)\n",
    "            if sim:\n",
    "                sum1 += sim*(self.userEventScores[u, item] - uu)\n",
    "                sum2 += sim\n",
    "        if sum2:\n",
    "            ans = uu + sum1/sum2\n",
    "    if ans > 1:\n",
    "        ans = 1\n",
    "    elif ans < -1:\n",
    "        ans = -1\n",
    "    else:\n",
    "        pass\n",
    "  \n",
    "    return ans\n",
    "    \n",
    "  def svdCFReco(self, userId, eventId):\n",
    "    #基于模型的协同过滤, SVD++/LFM\n",
    "    u = self.userIndex[userId]\n",
    "    i = self.eventIndex[eventId]\n",
    "\n",
    "    return self.pred_SVD(u,i)\n",
    "\n",
    "  def userReco(self, userId, eventId):\n",
    "    \"\"\"\n",
    "    类似基于User-based协同过滤，只是用户之间的相似度由用户本身的属性得到，计算event的推荐度\n",
    "    基本的伪代码思路如下：\n",
    "    for item i\n",
    "      for every other user v that has a preference for i\n",
    "        compute similarity s between u and v\n",
    "        incorporate v's preference for i weighted by s into running aversge\n",
    "    return top items ranked by weighted average\n",
    "    \"\"\"\n",
    "    i = self.userIndex[userId]\n",
    "    j = self.eventIndex[eventId]\n",
    "\n",
    "    vs = self.userEventScores[:, j]\n",
    "    sims = self.userSimMatrix[i, :]\n",
    "\n",
    "    prod = sims * vs\n",
    "\n",
    "    try:\n",
    "      return prod[0, 0] - self.userEventScores[i, j]\n",
    "    except IndexError:\n",
    "      return 0\n",
    "\n",
    "  def eventReco(self, userId, eventId):\n",
    "    \"\"\"\n",
    "    类似基于Item-based协同过滤，只是item之间的相似度由item本身的属性得到，计算Event的推荐度\n",
    "    基本的伪代码思路如下：\n",
    "    for item i \n",
    "      for every item j that u has a preference for\n",
    "        compute similarity s between i and j\n",
    "        add u's preference for j weighted by s to a running average\n",
    "    return top items, ranked by weighted average\n",
    "    \"\"\"\n",
    "    i = self.userIndex[userId]\n",
    "    j = self.eventIndex[eventId]\n",
    "    js = self.userEventScores[i, :]\n",
    "    psim = self.eventPropSim[:, j]\n",
    "    csim = self.eventContSim[:, j]\n",
    "    pprod = js * psim\n",
    "    cprod = js * csim\n",
    "    \n",
    "    pscore = 0\n",
    "    cscore = 0\n",
    "    try:\n",
    "      pscore = pprod[0, 0] - self.userEventScores[i, j]\n",
    "    except IndexError:\n",
    "      pass\n",
    "    try:\n",
    "      cscore = cprod[0, 0] - self.userEventScores[i, j]\n",
    "    except IndexError:\n",
    "      pass\n",
    "    return pscore, cscore\n",
    "\n",
    "  def userPop(self, userId):\n",
    "    \"\"\"\n",
    "    基于用户的朋友个数来推断用户的社交程度\n",
    "    主要的考量是如果用户的朋友非常多，可能会更倾向于参加各种社交活动\n",
    "    \"\"\"\n",
    "    if userId in self.userIndex:\n",
    "      i = self.userIndex[userId]\n",
    "      try:\n",
    "        return self.numFriends[0, i]\n",
    "      except IndexError:\n",
    "        return 0\n",
    "    else:\n",
    "      return 0\n",
    "\n",
    "  def friendInfluence(self, userId):\n",
    "    \"\"\"\n",
    "    朋友对用户的影响\n",
    "    主要考虑用户所有的朋友中，有多少是非常喜欢参加各种社交活动/event的\n",
    "    用户的朋友圈如果都积极参与各种event，可能会对当前用户有一定的影响\n",
    "    \"\"\"\n",
    "    nusers = np.shape(self.userFriends)[1]\n",
    "    i = self.userIndex[userId]\n",
    "    return (self.userFriends[i, :].sum(axis=0) / nusers)[0,0]\n",
    "\n",
    "  def eventPop(self, eventId):\n",
    "    \"\"\"\n",
    "    本活动本身的热度\n",
    "    主要是通过参与的人数来界定的\n",
    "    \"\"\"\n",
    "    i = self.eventIndex[eventId]\n",
    "    return self.eventPopularity[i, 0]\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def generateRSData(RS, train=True, header=True):\n",
    "    \"\"\"\n",
    "    把前面user-based协同过滤 和 item-based协同过滤，以及各种热度和影响度作为特征组合在一起\n",
    "    生成新的训练数据，用于分类器分类使用\n",
    "    \"\"\"\n",
    "    fin_file_title,fout_file_title = (train_file_title, RS_train_file_title) if train else (test_file_title, RS_test_file_title)\n",
    "    fin = open(fin_file_title, 'rb')\n",
    "    \n",
    "    fout = open(fout_file_title, 'wb')\n",
    "    \n",
    "    #忽略第一行（列名字）\n",
    "    fin.readline().strip().split(b\",\")\n",
    "    \n",
    "    # write output header\n",
    "    if header:\n",
    "      ocolnames = [b\"invited\", b\"userCF_reco\", b\"evtCF_reco\",b\"svdCF_reco\",b\"user_reco\", b\"evt_p_reco\",\n",
    "        b\"evt_c_reco\", b\"user_pop\", b\"frnd_infl\", b\"evt_pop\"]\n",
    "      if train:\n",
    "        ocolnames.append(b\"interested\")\n",
    "        ocolnames.append(b\"not_interested\")\n",
    "      fout.write(b\",\".join(ocolnames) + b\"\\n\")\n",
    "    \n",
    "    ln = 0\n",
    "    for line in fin:\n",
    "      ln += 1\n",
    "      if ln%500 == 0:\n",
    "          print(\"%s:%d (userId, eventId)=(%s, %s)\" % (fin_file_title, ln, userId, eventId))\n",
    "          #break;\n",
    "      \n",
    "      cols = line.strip().split(b\",\")\n",
    "      userId = cols[0]\n",
    "      eventId = cols[1]\n",
    "      invited = cols[2]\n",
    "      \n",
    "      userCF_reco = RS.userCFReco(userId, eventId)\n",
    "      itemCF_reco = RS.eventCFReco(userId, eventId)\n",
    "      svdCF_reco = RS.svdCFReco(userId, eventId)\n",
    "        \n",
    "      user_reco = RS.userReco(userId, eventId)\n",
    "      evt_p_reco, evt_c_reco = RS.eventReco(userId, eventId)\n",
    "      user_pop = RS.userPop(userId)\n",
    "     \n",
    "      frnd_infl = RS.friendInfluence(userId)\n",
    "      evt_pop = RS.eventPop(eventId)\n",
    "      ocols = [invited, userCF_reco, itemCF_reco, svdCF_reco,user_reco, evt_p_reco,\n",
    "        evt_c_reco, user_pop, frnd_infl, evt_pop]\n",
    "      \n",
    "      if train:\n",
    "        ocols.append(cols[4]) # interested\n",
    "        ocols.append(cols[5]) # not_interested\n",
    "      fout.write(b\",\".join(map(lambda x: str(x).encode(), ocols)) + b\"\\n\")\n",
    "    \n",
    "    fin.close()\n",
    "    fout.close()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SVD trained, loss  848.1167898011295\n",
      "生成训练数据...\n",
      "\n",
      "data\\train.csv:500 (userId, eventId)=(b'123290209', b'1887085024')\n",
      "data\\train.csv:1000 (userId, eventId)=(b'272886293', b'199858305')\n",
      "data\\train.csv:1500 (userId, eventId)=(b'395305791', b'1582270949')\n",
      "data\\train.csv:2000 (userId, eventId)=(b'527523423', b'3272728211')\n",
      "data\\train.csv:2500 (userId, eventId)=(b'651258472', b'792632006')\n",
      "data\\train.csv:3000 (userId, eventId)=(b'811791433', b'524756826')\n",
      "data\\train.csv:3500 (userId, eventId)=(b'985547042', b'1269035551')\n",
      "data\\train.csv:4000 (userId, eventId)=(b'1107615001', b'173949238')\n",
      "data\\train.csv:4500 (userId, eventId)=(b'1236336671', b'3849306291')\n",
      "data\\train.csv:5000 (userId, eventId)=(b'1414301782', b'2652356640')\n",
      "data\\train.csv:5500 (userId, eventId)=(b'1595465532', b'955398943')\n",
      "data\\train.csv:6000 (userId, eventId)=(b'1747091728', b'2131379889')\n",
      "data\\train.csv:6500 (userId, eventId)=(b'1914182220', b'955398943')\n",
      "data\\train.csv:7000 (userId, eventId)=(b'2071842684', b'1076364848')\n",
      "data\\train.csv:7500 (userId, eventId)=(b'2217853337', b'3051438735')\n",
      "data\\train.csv:8000 (userId, eventId)=(b'2338481531', b'2525447278')\n",
      "data\\train.csv:8500 (userId, eventId)=(b'2489551967', b'520657921')\n",
      "data\\train.csv:9000 (userId, eventId)=(b'2650493630', b'87962584')\n",
      "data\\train.csv:9500 (userId, eventId)=(b'2791418962', b'4223848259')\n",
      "data\\train.csv:10000 (userId, eventId)=(b'2903662804', b'2791462807')\n",
      "data\\train.csv:10500 (userId, eventId)=(b'3036141956', b'3929507420')\n",
      "data\\train.csv:11000 (userId, eventId)=(b'3176074542', b'3459485614')\n",
      "data\\train.csv:11500 (userId, eventId)=(b'3285425249', b'2271782630')\n",
      "data\\train.csv:12000 (userId, eventId)=(b'3410667855', b'1063772489')\n",
      "data\\train.csv:12500 (userId, eventId)=(b'3531604778', b'2584839423')\n",
      "data\\train.csv:13000 (userId, eventId)=(b'3686871863', b'53495098')\n",
      "data\\train.csv:13500 (userId, eventId)=(b'3833637800', b'2415873572')\n",
      "data\\train.csv:14000 (userId, eventId)=(b'3944021305', b'2096772901')\n",
      "data\\train.csv:14500 (userId, eventId)=(b'4075466480', b'3567240505')\n",
      "data\\train.csv:15000 (userId, eventId)=(b'4197193550', b'1628057176')\n",
      "生成预测数据...\n",
      "\n",
      "data\\test.csv:500 (userId, eventId)=(b'182290053', b'2529072432')\n",
      "data\\test.csv:1000 (userId, eventId)=(b'433510318', b'4244463632')\n",
      "data\\test.csv:1500 (userId, eventId)=(b'632808865', b'2845303452')\n",
      "data\\test.csv:2000 (userId, eventId)=(b'813611885', b'2036538169')\n",
      "data\\test.csv:2500 (userId, eventId)=(b'1010701404', b'303459881')\n",
      "data\\test.csv:3000 (userId, eventId)=(b'1210932037', b'2529072432')\n",
      "data\\test.csv:3500 (userId, eventId)=(b'1452921099', b'2705317682')\n",
      "data\\test.csv:4000 (userId, eventId)=(b'1623287180', b'1626678328')\n",
      "data\\test.csv:4500 (userId, eventId)=(b'1855201342', b'2603032829')\n",
      "data\\test.csv:5000 (userId, eventId)=(b'2083900381', b'2529072432')\n",
      "data\\test.csv:5500 (userId, eventId)=(b'2318415276', b'2509151803')\n",
      "data\\test.csv:6000 (userId, eventId)=(b'2528161539', b'4025975316')\n",
      "data\\test.csv:6500 (userId, eventId)=(b'2749110768', b'4244406355')\n",
      "data\\test.csv:7000 (userId, eventId)=(b'2927772127', b'1532377761')\n",
      "data\\test.csv:7500 (userId, eventId)=(b'3199685636', b'1776393554')\n",
      "data\\test.csv:8000 (userId, eventId)=(b'3393388475', b'680270887')\n",
      "data\\test.csv:8500 (userId, eventId)=(b'3601169721', b'154434302')\n",
      "data\\test.csv:9000 (userId, eventId)=(b'3828963415', b'3067222491')\n",
      "data\\test.csv:9500 (userId, eventId)=(b'4018723397', b'2522610844')\n",
      "data\\test.csv:10000 (userId, eventId)=(b'4180064266', b'2658555390')\n"
     ]
    }
   ],
   "source": [
    "RS = RecommonderSystem()\n",
    "print(\"生成训练数据...\\n\")\n",
    "generateRSData(RS,train=True,  header=True)\n",
    "\n",
    "print(\"生成预测数据...\\n\")\n",
    "generateRSData(RS, train=False, header=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "时间、地点等特征都没有处理了，可以考虑用户看到event的时间与event开始时间的差、用户地点和event地点的差异。。。"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
